﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Nb.Common
{
    [TestClass]
    public class NbServiceManagerTest
    {
        [TestMethod]
        public void SameTypeInstance_Should_Unique()
        {
            var nbServiceManager = MyManager.Instance;
            var nbServiceManager2 = MyManager.Instance;
            Assert.AreSame(nbServiceManager, nbServiceManager2);

        }

        [TestMethod]
        public void DifferentTypeInstance_Should_NotUnique()
        {
            var nbServiceManager = MyManager.Instance;
            var nbServiceManager2 = MyManager2.Instance;
            Assert.AreNotSame(nbServiceManager, nbServiceManager2);
        }
    }

    #region demo

    public interface IMyService
    {
        string GetName();
    }

    public class MyManager : NbServiceManager<IMyService>
    {
    }

    public class MyManager2 : NbServiceManager<IMyService>
    {
    }

    #endregion
}
